package designmodel.handler.raiseSalary;

import java.text.MessageFormat;
import java.util.Objects;

/**
 * 抽象管理者
 *
 * @author scylla
 * @version V1.0
 * @project echo -java-base
 * @title 抽象管理者
 * @package designmodel.handler.raiseSalary
 * @since 2022 /5/19 6:21 下午
 */
public abstract class AbstractManager {

    /**
     * The constant QINGJIA.
     */
    public static final String QINGJIA = "1";
    /**
     * The constant JIAXIN.
     */
    public static final String JIAXIN = "2";
    /**
     * The Name.
     */
    protected String name;

    /**
     * The Abstract manager.
     */
    protected AbstractManager abstractManager;

    public AbstractManager(String name) {
        this.name = name;
    }

    /**
     * Do final.
     *
     * @param oaRequest the oa request
     */
    public void doNext(OARequest oaRequest) {
        if (Objects.isNull(abstractManager)) {
            //进入最终处理
            doFinal(oaRequest);
        } else {
            this.abstractManager.doApproval(oaRequest);
        }
    }

    /**
     * Do final.
     *
     * @param oaRequest the oa request
     */
    public void doFinal(OARequest oaRequest) {
        System.out.println(MessageFormat.format("未找到OA申请： {0} 对应的审批人，审批被驳回", oaRequest.toString()));
    }

    /**
     * Sets superior.
     *
     * @param abstractManager the abstract manager
     * @return the superior
     */
    public AbstractManager superior(AbstractManager abstractManager) {
        this.abstractManager = abstractManager;
        return this.abstractManager;
    }

    /**
     * Do approval.
     *
     * @param oaRequest the oa request
     */
    public abstract void doApproval(OARequest oaRequest);

}
